package headfirst.designpatterns.factory.a_pizzas_simpleFactory.store;

import headfirst.designpatterns.factory.a_pizzas_simpleFactory.factory.SimplePizzaFactory;
import headfirst.designpatterns.factory.a_pizzas_simpleFactory.pizza.Pizza;

public class PizzaStore {
    SimplePizzaFactory factory;

    public PizzaStore(SimplePizzaFactory factory) {
        this.factory = factory;
    }

    public Pizza orderPizza(String type) {
        // 开始制作披萨
        Pizza pizza;
        // 把new操作符 替换 成工厂对象的创建方法，不再使用具体的实力化
        pizza = factory.createPizza(type);

        // 准备工作（每一个子类型都知道如何准备自己————都有自己的实现类）
        pizza.prepare();
        // 烘焙
        pizza.bake();
        // 切割
        pizza.cut();
        // 装盒
        pizza.box();

        return pizza;
    }
}
